package com.ctshk.sapp.finance.controller;


import com.ctshk.common.annotations.OperationLogAnnotation;
import com.ctshk.common.dto.Result;
import com.ctshk.common.enums.OperationLogModel;
import com.ctshk.common.enums.OperationLogType;
import com.ctshk.common.model.PageResponse;
import com.ctshk.rpc.finance.dto.paidin.PaidInListDTO;
import com.ctshk.rpc.finance.dto.supplier.SupplierDataDTO;
import com.ctshk.rpc.finance.dto.supplier.SupplierDataListDTO;
import com.ctshk.rpc.finance.req.paidin.PaidInListReq;
import com.ctshk.rpc.finance.req.supplier.SupplierDataAddReq;
import com.ctshk.rpc.finance.req.supplier.SupplierDataIdReq;
import com.ctshk.rpc.finance.req.supplier.SupplierDataListReq;
import com.ctshk.rpc.finance.service.IFinanceSupplierDataService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;
import com.ctshk.common.web.support.BaseController;

import javax.validation.Valid;

/**
 * <p>
 * 供应商期初 前端控制器
 * </p>
 *
 * @author 叶冠峰
 * @since 2021-04-12
 */
@RestController
@Api(value = "供应商期初", tags = "供应商期初")
@RequestMapping("/finance-supplier-data")
public class FinanceSupplierDataController extends BaseController {

    @DubboReference
    private IFinanceSupplierDataService supplierDataService;


    @ApiOperation(value = "列表", notes = "列表（叶冠峰）")
    @OperationLogAnnotation(operModul = OperationLogModel.FINANCE, operType = OperationLogType.QUERY, operTitle = "供应商期初-列表", operDesc = "供应商期初-列表")
    @PostMapping("/list")
    public Result<PageResponse<SupplierDataListDTO>> list(@RequestBody SupplierDataListReq req) {
        req.setUserId(getCurrentUser(getRequest()).getId());
        return supplierDataService.list(req);
    }

    @ApiOperation(value = "详情", notes = "详情（叶冠峰）")
    @OperationLogAnnotation(operModul = OperationLogModel.FINANCE, operType = OperationLogType.QUERY, operTitle = "供应商期初-详情", operDesc = "供应商期初-详情")
    @PostMapping("/detail")
    public Result<SupplierDataDTO> detail(@RequestBody @Valid SupplierDataIdReq req) {
        return supplierDataService.detail(req);
    }

    @ApiOperation(value = "新增", notes = "新增（叶冠峰）")
    @OperationLogAnnotation(operModul = OperationLogModel.FINANCE, operType = OperationLogType.ADD, operTitle = "供应商期初-新增", operDesc = "供应商期初-新增")
    @PostMapping("/add")
    public Result add(@RequestBody @Valid SupplierDataAddReq req) {
        req.setUserId(getCurrentUser(getRequest()).getId());
        return supplierDataService.add(req);
    }

}
